<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>sessionStorage</title>
</head>

<body>
    <button onclick="save()">点我保存一个数据</button>
    <button onclick="printt()">点我打印一个数据</button>
    <script>
        let p = { 'name': 'huhi', 'age': 18 }
        function save() {
            sessionStorage.setItem('msg', 'hello')
            sessionStorage.setItem('person', JSON.stringify(p))
            console.log(typeof p);
        }
        function printt() {
            let p = sessionStorage.getItem('person')
            let res = JSON.parse(p)
            console.log(typeof p);
        }
    </script>
</body>

</html>